<template>
	<view class="container">
		<view class="swiper square">
			<swiper class="skeleton-rect" indicator-dots="true"
				:autoplay="true" :circular="circular" :interval="interval" :duration="duration"
				indicator-color="rgba(255,255,255,0.6)" indicator-active-color="#fff" :current="swiperCur"
				@change="swiperChange" style="height: 400rpx;">
				<block v-for="(item,index) in imgUrls" :key="index">
					<swiper-item class="" :class="{active:index == swiperCur}">
						<view style="height: 400rpx;" @click="goDetail(item)" class='slide-navigator acea-row row-between-wrapper'>
							<image :src="item" class="slide-image">
							</image>
						</view>
					</swiper-item>
				</block>
		
			</swiper>
		</view><!-- 轮播图 end -->
		<view class="info_container">
			<view class="intro_bg">
				<view class="ib_left">
					<view class="name">{{data.real_name}} <view class="score">{{data.score}}分</view></view>
					<view class="address">{{data.address}}</view>
				</view>
				<view class="ib_right">
					<image class="loction" src="../../static/images/weizhi.png"></image>
				</view>
			</view><!-- intro_bg end-->
			<view class="tec-bg">
				<!-- <view class="title">技能证书</view> -->
				<view class="content">
					<view class="tag" v-for="t in data.tecs">{{t.title}}</view>
				</view>
				<view class="col">
					<image class="coll" v-if="!check" @click="collEvent()" src="../../static/images/coll_normal.png"></image>
					<image class="coll" v-if="check" @click="collEvent()" src="../../static/images/coll_selected.png"></image>
				</view>
			</view>
			<view class="item-bg">
				<view class="title">擅长项目</view>
				<view class="content">
					<view class="tag" v-for="i in data.items">{{i.name}}</view>
				</view>
			</view>
			<!-- 收藏用户 -->
			<view class="collec" style="display: none;">
				<view class="title">收藏用户</view>
				<view class="content">
					<image class="avatar" v-for="n in 10" src="../../static/images/f.png"></image>
				</view>
			</view>
			<!-- 收藏用户 end -->
			<!-- 购买须知 -->
			<view class="intro">
				<view class="title">详细简介</view>
				<view class="content">
					<parser :html="data.intro" ref="article" :tag-style="tagStyle"></parser>
				</view>
			</view>
			<!-- 购买须知 end -->
		</view><!--info-->
		<view class="footer">
			<view class="buy" @click="goBuy()">联系技工</view>
		</view>
	</view>
</template>

<script>
	import {toLogin} from "@/libs/login.js";
	import {mapGetters} from "vuex";
	import parser from "@/components/jyf-parser/jyf-parser";
	import {tecer_info} from "@/api/platform.js";
	
	// #ifdef MP
	import authorize from "@/components/Authorize";
	// #endif
	export default {
		components: {
			parser,
			// #ifdef MP
			authorize,
			// #endif
		},
		data() {
			return {
				showSkeleton: true, //骨架屏显示隐藏
				indicatorDots: false,
				circular: true,
				autoplay: true,
				interval: 4000,
				duration: 500,
				imgUrls: [
					// 'https://imagepphcloud.thepaper.cn/pph/image/90/390/588.jpg'
				], //图片轮播数据
				data:{
					name:'',
					price:0.00
				},
				know:'',
				tagStyle: {
					img: "width:100%;display:block;",
					table: "width:100%",
					video: "width:100%;height:100%;",
				},
				isAuto: false, //没有授权的不会自动授权
				isShowAuth: false, //是否隐藏授权
				id:0,
				check:false,
			}
		},
		computed: mapGetters(["isLogin"]),
		watch: {
			isLogin: {
				handler: function(newV, oldV) {
					if (newV == true) {
						console.info(111)
						// this.getCouponList();
						// this.getCartCount();
						// this.downloadFilePromotionCode();
					}
				},
				deep: true,
			}
		},
		onLoad(options) {
			this.id = options.id;
			this.getData();
		},
		methods: {
			collEvent(){
				this.check = !this.check;
			},
			getData(){
				let that = this;
				uni.showLoading({
					title:'加载中...'
				});
				tecer_info(this.id).then((res) => {
					let data = res.data;
					that.data = data;
					let carousel = data.carousel;
					if(carousel){
						that.imgUrls = carousel.split(',');
					}
					// that.know = data.know;
					// that.content = data.content;
					uni.hideLoading();
				});
			},
			goBuy(){
				if (this.isLogin === false) {
					toLogin();
				} else {
					console.info('已登录')
					this.goCat(true);
				}
			},
			goCat(){
				uni.navigateTo({
					url:'/pages/tecer/confirm'
				})
			},
			swiperChange(e){
				
			},
			goDetail(item){
				
			},
			gotoDetail(){
				uni.navigateTo({
					url:'../detail/index'
				})
			}
		}
	}
</script>

<style lang="scss" scope>
	.container {
		background-color: #F5F5F5;
		padding-bottom: 0;
		padding-bottom: constant(safe-area-inset-bottom);  
		padding-bottom: env(safe-area-inset-bottom); 
	}
	.swiper{
		padding: 0 0;
		.slide-image{
			width: 100%; 
			height: 400rpx;
		}
	}
	
	.info_container{
		display: flex;
		flex-direction: column;
		background-color: white;
		padding-bottom: 100rpx;
		// margin-bottom: calc(100rpx+ constant(safe-area-inset-bottom));
		// margin-bottom: calc(100rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
		// margin-bottom: calc(100rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
		// padding: 20rpx;
		
		.intro_bg{
			display: flex;
			flex-direction: row;
			justify-content: space-between;	
			padding: 30rpx;
			
			.ib_left{
				display: flex;
				flex-direction: column;
				.name{
					display: flex;
					flex-direction: row;
					align-items: center;
					font-size: 36rpx;
					color: black;
					.score{
						font-size: 28rpx;
						font-weight: bold;
						color: #93ce9b;
						background-color: #f4f5ef;
						padding: 0rpx 10rpx;
						border-radius: 10rpx;
						margin-left: 15rpx;
					}
				}
				.address{
					margin-top: 15rpx;
					color: darkgray;
					font-size: 26rpx;
				}
			}
			.ib_right{
				margin-left: 20rpx;
				display: flex;
				flex-direction: row;
				align-items: center;
				justify-content: center;
				.loction{
					width: 40rpx;
					height:40rpx;
				}
			}
		}
		.collec{
			display: flex;
			flex-direction: column;
			padding: 30rpx;
			border-top: 10rpx solid #f3f3f3;
			.title{
				font-size: 30rpx;
				font-weight: bold;
				color: black;
			}
			.content{
				margin-top: 40rpx;
				color: black;
				display: flex;
				flex-direction: row;
				flex-wrap: wrap;
				padding-left: 30rpx;
				.avatar{
					width: 80rpx;
					height:80rpx;
					border-radius: 40rpx;
					margin-left: -20rpx;
				}
				.avatar2{
					width: 100rpx;
					height:100rpx;
					border-radius: 50rpx;
					margin-left: -30rpx;
				}
			}
		}
		.tec-bg{
			display: flex;
			flex-direction: row;
			padding: 0rpx 30rpx 30rpx 30rpx;
			.content{
				color: black;
				display: flex;
				flex-direction: row;
				flex-wrap: wrap;
				flex: 1;
				.tag{
					padding: 5rpx 10rpx;
					background-color: #e9f1f6;
					color: #5792db;
					font-size: 28rpx;
					margin-right: 10rpx;
					border-radius: 10rpx;
				}
			}
			.col{
				margin-left: 15rpx;
				display: flex;
				flex-direction: row;
				justify-content: center;
				.coll{
					width: 50rpx;
					height: 50rpx;
				}
			}
		}
		.item-bg{
			display: flex;
			flex-direction: column;
			padding: 30rpx;
			border-top: 10rpx solid #f3f3f3;
			.title{
				font-size: 30rpx;
				font-weight: bold;
				color: black;
			}
			.content{
				margin-top: 40rpx;
				color: black;
				display: flex;
				flex-direction: row;
				flex-wrap: wrap;
				.tag{
					padding: 5rpx 10rpx;
					background-color: #e9f1f6;
					color: #5792db;
					font-size: 28rpx;
					margin-right: 10rpx;
					border-radius: 10rpx;
				}
			}
		}
		.intro{
			display: flex;
			flex-direction: column;
			padding: 30rpx;
			border-top: 10rpx solid #f3f3f3;
			.title{
				font-size: 30rpx;
				font-weight: bold;
				color: black;
			}
			.content{
				margin-top: 40rpx;
				color: black;
			}
		}
	}
	.footer {
		padding: 0 20rpx 0 30rpx;
		position: fixed;
		bottom: 0;
		width: 100%;
		box-sizing: border-box;
		background-color: #fff;
		z-index: 277;
		border-top: 1rpx solid #f0f0f0;
		height: 100rpx;
		height: calc(100rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
		height: calc(100rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
		display: flex;
		flex-direction: row;
		justify-content: center;
		.buy{
			margin-top: 10rpx;
			width: 95%;
			height: 80rpx;
			border-radius: 40rpx;
			background-color: red;
			color: white;
			font-size: 28rpx;
			text-align: center;
			line-height: 80rpx;
		}
	}
</style>
